﻿# -*-coding: UTF-8 -*-

class EventSignal:

	def __init__(self, name):
		self.name = name
		self.functions = []

	def __repr__(self):
		return f'<Signal|{self.name}>'

	def __str__(self):
		return f'<Signal|{self.name}>'

	def connect(self, function):
		if function in self.functions:
			return
		self.functions.append(function)

	def disconnect(self, function):
		if function in self.functions:
			self.functions.remove(function)

	def emit(self, *args, **kwargs):
		for function in self.functions:
			function and function(*args, **kwargs)
